// Copyright (C) ZHENG Zhong <heavyzheng nospam-at gmail D0T com>
//
// $Id: duration.hpp 225 2008-09-12 17:43:02Z heavyzheng $
//

#ifndef ZZHENG_QUANT_DATES_DURATION_HPP_20080602__
#define ZZHENG_QUANT_DATES_DURATION_HPP_20080602__

#include <zzheng/quant/dates/config.hpp>
#include <string>

namespace zzheng {
namespace quant {
namespace dates {

    class duration {

    public:

        typedef int count_type;

        enum unit_type {
            unknown = 0,   //!< Unknown unit (error).
            day     = 1,   //!< One day.
            week    = 7,   //!< One week.
            month   = 30,  //!< One month.
            year    = 360, //!< One year.
        };

    public:

        ////////////////////////////////////////////////////////////////////////////////////////////
        // constructors
        //

        explicit duration();

        explicit duration(count_type count, unit_type unit);

        // Use auto-generated copy constructor.
        // Use auto-generated copy assignment.
        // Use auto-generated destructor.

        ////////////////////////////////////////////////////////////////////////////////////////////
        // operators
        //

        bool operator==(const duration& rhs) const;

        bool operator<(const duration& rhs) const;

        bool operator!=(const duration& rhs) const;

        bool operator>(const duration& rhs) const;

        bool operator<=(const duration& rhs) const;

        bool operator>=(const duration& rhs) const;

        //! Negative operator that returns the negative value of this duration.
        duration operator-() const;

        duration operator*(int multiplier) const;

        ////////////////////////////////////////////////////////////////////////////////////////////
        // public member functions
        //

        void swap(duration& rhs);

        bool empty() const;

        count_type count() const;

        unit_type unit() const;

        count_type daycount() const;

        std::string str() const;

    private:

        count_type count_; //!< The count of this duration.
        unit_type  unit_;  //!< The unit of this duration.

    }; // class duration

} // namespace zzheng::quant::dates
} // namespace zzheng::quant
} // namespace zzheng


#endif // ZZHENG_QUANT_DATES_DURATION_HPP_20080602__





